﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using ThuPhap.Models;
using System.Collections.Generic;

namespace ThuPhap.ViewModels
{
    public class FontViewModel
    {
        public List<FontFamilyManage> Items { get; set; }
        public bool IsDataLoaded { get; private set; }
        public FontViewModel()
        {
            this.Items = new List<FontFamilyManage>();
        }

        public void LoadData()
        {
            var allFonts = new FontFamilyManage().Load();
            foreach (var item in allFonts)
            {
                Deployment.Current.Dispatcher.BeginInvoke(new AddItemToFontDelegate(AddItemToFont), item);
            }
            this.IsDataLoaded = true;
        }

        public delegate void AddItemToFontDelegate(FontFamilyManage Font);
        private void AddItemToFont(FontFamilyManage Font)
        {
            App.FontViewModel.Items.Insert(0,Font);
        }
    }
}
